package cn.amlove.noteken.file;

import java.io.File;

public class OpenFile {

	private String encoding = "utf-8";
	private String fileType = FileType.TEXT;
	private String contentType = ContentType.TEXT;
	private File file;
	private boolean canRead = false;
	private boolean canWrite = false;

	public OpenFile(File file) {
		this.file = file;
		
		if (file.exists())
		{
			this.canRead = file.canRead();
			this.canWrite = file.canWrite();
			this.fileType = FileUtil.getFileType(file.getName());
			this.contentType = FileUtil.getContentType(file.getName());
			this.encoding = FileUtil.getFileEncoding(file);
		}
	}

	public String getEncoding() {
		return encoding;
	}

	public String getFileType() {
		return fileType;
	}

	public String getContentType() {
		return contentType;
	}

	public File getFile() {
		return file;
	}

	public boolean isCanRead() {
		return canRead;
	}

	public boolean isCanWrite() {
		return canWrite;
	}

}
